<template>
<div v-loading="loading">
<el-container style="margin-top: -30px; margin-left: 10px;">
  <div><h2>最近未激活的密钥</h2></div>
</el-container>
  <el-table :data="tableData" style="width: 90%">
    <el-table-column type="index" :index="1" label="序号" width="80"> </el-table-column>
    <el-table-column prop="key" label="密钥" width="350"> </el-table-column>
    <el-table-column prop="duration" label="时长" width="100"> </el-table-column>
    <el-table-column prop="note" label="备注" width="150"> </el-table-column>
    <el-table-column prop="from_who" label="创建人" width="150"> </el-table-column>
  </el-table>
</div>
</template>

<script>
import axios from 'axios';
import { ElMessage } from 'element-plus';
export default {
  data() {
    axios.get("/api/queryKeys",{
      params: {
        auth: localStorage.getItem("auth_key")
      }
    })
    .then(res => {
      console.log(res)
      if(res.data.count == 0){
        ElMessage.warning("未查询到相关数据");
      }
      this.tableData = res.data.data;
      this.loading = false
    })
    .catch(err => {
      console.error(err); 
      this.loading = false;
      ElMessage.error("加载失败")
    })
    return {
      loading: true,
      tableData: []
    };
  },
};
</script>

<style lang="scss" scoped>
</style>